package work.jame.blog.pojo.dto;

import io.swagger.annotations.ApiModel;
import org.springframework.validation.annotation.Validated;
import work.jame.blog.framework.VerificationGroup;
import work.jame.blog.pojo.Article;
import work.jame.blog.pojo.ArticleTag;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author : Jame
 * @date : 2023-05-17 11:13
 **/
@ApiModel(description = "文章包装类")
public class ArticleDTO {

    /**
     * 文章本体
     */
    @NotNull(message = "用户数据不能为空",
            groups = {
                    VerificationGroup.Save.class,
                    VerificationGroup.Update.class
            }
    )
    @Valid //嵌套检查
    private Article article;

    /**
     * 文章对应的标签
     */
    @NotNull(message = "标签集合为空",
            groups = {VerificationGroup.Save.class,
                    VerificationGroup.Update.class})
    private List<ArticleTag> articleTags;

    public Article getArticle() {
        return article;
    }

    public void setArticle(Article article) {
        this.article = article;
    }

    public List<ArticleTag> getArticleTags() {
        return articleTags;
    }

    public void setArticleTags(List<ArticleTag> articleTags) {
        this.articleTags = articleTags;
    }

    @Override
    public String toString() {
        return "ArticleDTO{" +
                "article=" + article +
                ", articleTags=" + articleTags +
                '}';
    }
}
